package com.wanshi.dao;

import com.wanshi.entity.City;
import com.wanshi.entity.User;
import com.wanshi.utils.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CityDao {

    //3 根据用户名查找用户
    public List<City> findCitys(){
        QueryRunner runner = new QueryRunner(JDBCUtil.getSource());

        String sql = "select  * from tb_citys";
        try {
            return runner.query(sql,new BeanListHandler<>(City.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
